<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:53:"E:\WWW\waimai/app/admin/shop\view\shop_goods\add.html";i:1501496315;s:53:"E:\WWW\waimai/app/admin/index\view\template\base.html";i:1495522842;}*/ ?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href="__STATIC__/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <!--图标字体元件库-->
    <link rel="stylesheet" href="__STATIC__/plugins/font-awesome4.5.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="__STATIC__/admin/css/AdminLTE.min.css">
    <link rel="stylesheet" href="__STATIC__/admin/css/jquery.datetimepicker.css">
    <link rel="stylesheet" href="__STATIC__/admin/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="__STATIC__/plugins/validform/5.3.2/css/Validateform_v5.3.2.css">

    <link rel="stylesheet" href="__STATIC__/plugins/bootstrap-table/bootstrap-table.min.css">
    <link rel="stylesheet" href="__STATIC__/plugins/iCheck/polaris/polaris.css">
    <link rel="stylesheet" href="__STATIC__/plugins/iCheck/futurico/futurico.css">
    <link rel="stylesheet" href="__STATIC__/plugins/iCheck/line/_all.css">
    <link rel="stylesheet" href="__STATIC__/plugins/iCheck/square/_all.css">
    <link rel="stylesheet" href="__STATIC__/plugins/iCheck/flat/_all.css">
    <link rel="stylesheet" href="__STATIC__/plugins/iCheck/minimal/_all.css">
    
<style>
    .nav-tabs-custom .nav-tabs {
        min-height: 100%;
        float: left;
        width: 15%;
    }

    .nav-tabs-custom .nav-tabs li {
        float: none;
        width: 100%;
    }

    .nav-tabs-custom .tab-content {
        width: 85%;
        float: left;
    }

    .nav-tabs-custom > .nav-tabs > li.active {
        border-top-color: #fff;
        border-right-color: #00a0e9;
    }

    .nav-tabs-custom > .nav-tabs > li.active a {
        border-right-color: transcategory;
        color: #00a0e9;
    }

    .btn-botom {
        height: 50px;
        margin-right: 20px;
        text-align: right;
        position: fixed;
        bottom: 0;
        right: 0;

    }
</style>
<link rel="stylesheet" href="__STATIC__/plugins/bootstrap-treeview/bootstrap-treeview.min.css">
<link href="__STATIC__/plugins/webuploader/custom/style.css" rel="stylesheet" type="text/css"/>
<!--<link rel="stylesheet" href="__STATIC__/plugins/select2/css/select2.min.css">-->


    <title><?php echo \think\Config::get('site.title'); ?></title>
    

    <script src="__STATIC__/plugins/jquery/jquery-3.0.0.min.js"></script>
    <script src="__STATIC__/plugins/bootstrap/js/bootstrap.min.js"></script>
    <script src="__STATIC__/admin/js/app.min.js"></script>
    <script src="__STATIC__/admin/extend/app.js"></script>

    <script src="__STATIC__/admin/extend/H-ui.admin.js"></script>
    <script src="__STATIC__/plugins/layer3.0.3/layer.js"></script>
    <script src="__STATIC__/plugins/validform/5.3.2/Validform_v5.3.2_min.js"></script>

    <script src="__STATIC__/plugins/bootstrap-table/bootstrap-table.min.js" type="text/javascript"></script>
    <script src="__STATIC__/plugins/bootstrap-table/bootstrap-table-zh-CN.js" type="text/javascript"></script>

    <script src="__STATIC__/plugins/iCheck/icheck.min.js"></script>
    <script>

        var admin_menu_data=<?php if(isset($admin_menu)): ?><?php echo $admin_menu; endif; ?>;
        $(function () {
            $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
                checkboxClass: 'icheckbox_minimal-blue',
                radioClass: 'iradio_minimal-blue'
            });
        })
    </script>

    
<script src="__STATIC__/plugins/bootstrap-treeview/bootstrap-treeview.min.js"></script>
<!--<script src="__STATIC__/plugins/select2/js/select2.full.min.js"></script>-->
<!--<script src="__STATIC__/plugins/select2/js/i18n/zh-CN.js"></script>-->

</head>
<body class="hold-transition skin-blue-light sidebar-mini">
    
<div class="wrapper">
    <div class="nav-tabs-custom">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="false">基本信息</a></li>
            <li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false">商品规格</a></li>
            <li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">详情</a></li>
            <li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false">图片</a></li>
            <!--<li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false">会员折扣</a></li>-->
        </ul>
        <form id="form" class="form-horizontal" autocomplete="off" action="<?php echo url('ShopGoods/insert'); ?>">
            <div class="tab-content">
                <div class="tab-pane active" id="tab_1">
                    <!--<label for="id_label_single">-->
                    <!--Click this to highlight the single select element-->

                    <!--<select class="js-example-basic-single js-states form-control" id="id_label_single"></select>-->
                    <!--</label>-->
                    <div class="box-body">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span style="color: red;">*</span>对应商家</label>
                            <div class="col-sm-6">
                                <select id="store" name='store_id' class="form-control select2" datatype="*"
                                        nullmsg="请选择对应商家">
                                    <?php if(is_array($store['rows']) || $store['rows'] instanceof \think\Collection || $store['rows'] instanceof \think\Paginator): $i = 0; $__LIST__ = $store['rows'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                                    <option value="<?php echo $vo['id']; ?>"><?php echo $vo['text']; ?></option>
                                    <?php endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </div>
                            <div class="col-sm-2"></div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span style="color: red;">*</span>商品分类</label>
                            <div class="col-sm-6">
                                <select id="cates" name='category_tree' class="form-control select2" datatype="*"
                                        nullmsg="请选择分类">
                                    <?php if(is_array($category['rows']) || $category['rows'] instanceof \think\Collection || $category['rows'] instanceof \think\Paginator): $i = 0; $__LIST__ = $category['rows'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                                    <option value="<?php echo $vo['id']; ?>"><?php echo $vo['name']; ?></option>
                                    <?php endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </div>
                            <div class="col-sm-2"></div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label"><span style="color: red;">*</span>商品名称</label>
                            <div class="col-sm-6">
                                <input class="form-control" type="text" name="name" datatype="*" nullmsg="请填写店铺名称">
                            </div>
                            <div class="col-sm-2"></div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">商品简介</label>
                            <div class="col-sm-6">
                                <textarea name="intro" class="form-control" rows="3" maxlength="255"></textarea>
                            </div>
                            <div class="col-sm-2"></div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">原价</label>
                            <div class="col-sm-6">
                                <div class="input-group">
                                    <span class="input-group-addon">￥</span>
                                    <input name="price_original" type="number" class="form-control"
                                           style="width: 100px;">
                                </div>
                            </div>
                            <div class="col-sm-2"></div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">价格</label>
                            <div class="col-sm-6">
                                <div class="input-group">
                                    <span class="input-group-addon">￥</span>
                                    <input name="price" type="number" class="form-control" style="width: 100px;">
                                </div>
                            </div>
                            <div class="col-sm-2"></div>
                        </div>
                        <!--<div class="form-group">-->
                        <!--<label class="col-sm-2 control-label">库存</label>-->
                        <!--<div class="col-sm-6">-->
                        <!--<input class="form-control" type="number" name="stock"  style="width: 139px;">-->
                        <!--</div>-->
                        <!--<div class="col-sm-2"></div>-->
                        <!--</div>-->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">销量</label>
                            <div class="col-sm-6">
                                <input class="form-control" type="number" name="sales" style="width: 139px;">
                            </div>
                            <div class="col-sm-2"></div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">排序</label>
                            <div class="col-sm-6">
                                <input class="form-control" type="number" name="sort" style="width: 139px;" value="0">
                            </div>
                            <div class="col-sm-2"></div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">是否推荐商品</label>
                            <div class="col-sm-6" style="margin-top: 7px">
                                <span class="mr20" style="padding-right: 20px"><input type="radio" class="minimal"
                                                                                      name="is_rec" value="0" checked> 否</span>
                                <span class="mr20"><input type="radio" class="minimal" name="is_rec" value="1"> 是</span>
                            </div>
                            <div class="col-sm-2"></div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">是否上架</label>
                            <div class="col-sm-6" style="margin-top: 7px">
                                <span class="mr20" style="padding-right: 20px"><input type="radio" class="minimal"
                                                                                      name="flag_putaway" value="0"> 下架</span>
                                <span class="mr20"><input type="radio" class="minimal" name="flag_putaway" value="1"
                                                          checked> 上架</span>

                            </div>
                            <div class="col-sm-2"></div>
                        </div>
                    </div>

                </div>
                <!-- /.tab-pane -->
                <div class="tab-pane" id="tab_2">
                    <div class="box-body">
                        <div class="form-group" style="margin-bottom: 5px;">
                            <div class="col-sm-1"></div>
                            <div class="panel panel-default col-sm-6" style="margin-bottom:5px;">
                                <div class="panel-body">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label"><span style="color: red;">*</span>型号</label>
                                        <div class="col-sm-6">
                                            <input class="form-control" type="text" name="variant_name[]" datatype="*" nullmsg="请填商品型号">
                                        </div>
                                        <div class="col-sm-2"></div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label"><span style="color: red;">*</span>价格</label>
                                        <div class="col-sm-6">
                                            <div class="input-group">
                                                <span class="input-group-addon">￥</span>
                                                <input name="variant_price[]" type="number" class="form-control" min="0" value="0" style="width: 100px;" datatype="*" nullmsg="请填商品价格">
                                            </div>
                                        </div>
                                        <div class="col-sm-2"></div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-1" ><a href="javascript:;" onclick="remove_variant(this)"><i class="fa fa-trash-o" style="padding-top: 50%;padding-left: 50%;color: #f32310;"></i></a></div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-7 control-label"><a id="variant-add" href="javascript:;"><i class="fa fa-plus"></i>&nbsp;添加商品型号</a></label>
                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="tab_3">
                    <div class="box-body">
                        <div class="form-group">
                            <div class="col-sm-11">
                                <!-- 加载编辑器的容器 -->
                                <script id="container1" name="detail" type="text/plain"
                                        style="height: 350px;border:none; width: 100%;"></script>
                                <!-- 配置文件 -->
                                <script type="text/javascript"
                                        src="__STATIC__/plugins/ueditor/ueditor.config.js"></script>
                                <!-- 编辑器源码文件 -->
                                <script src="__STATIC__/plugins/ueditor/ueditor.all.min.js"
                                        type="text/javascript"></script>
                                <!-- 实例化编辑器 -->
                                <script type="text/javascript">
                                    var ue = UE.getEditor('container1');
                                </script>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="tab-pane" id="tab_4">
                    <div class="box-body">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">封面图片</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-sm-6">
                                        <input id="simple" name="cover_image_id" type="hidden"/>
                                        <button type="button" class="btn btn-danger simple-upload">上传图片</button>
                                    </div>
                                    <div class="col-sm-6">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">商品幻灯图</label>
                            <div class="col-sm-10">
                                <div class="row">
                                    <div class="col-sm-6">
                                        <input id="multiple" name="slide_image_id" type="hidden"/>
                                        <button type="button" class="btn btn-danger multiple-upload">上传图片</button>
                                    </div>
                                    <div class="col-sm-6">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <div class="btn-botom">
                <button type="submit" class="btn btn-primary btn-submit">&nbsp;&nbsp;保存商品&nbsp;&nbsp;</button>
            </div>
        </form>
        <!-- /.tab-content -->
    </div>

</div>


</body>
<script src="__STATIC__/admin/js/skins_control.js"></script>
<script src="__STATIC__/admin/js/jquery.datetimepicker.js"></script>

<script>
    $("#store").on('change', function () {
        var url = "<?php echo url('ShopGoods/get_category'); ?>";
        var id = $(this).val();
        $.post(url, {store_id: id}, function (ret) {
            var listHTML = '';
            for (var i = 0; i < ret.rows.length; i++) {
                listHTML += '<option value="' + ret.rows[i].id + '">' + ret.rows[i].name + '</option>';
            }
            $('#cates').empty();
            $('#cates').append(listHTML);

        }, 'json');
    })

    $('.multiple-upload').on('click', function (e) {
        var ids = $("#multiple").val();
        layer_open('多图上传', "<?php echo url('/addons/web_uploader/upload/parent_ele/multiple/id/" + ids + "'); ?>", {
            w: "600px",
            h: "400px"
        })
    });
    $('.simple-upload').on('click', function (e) {
        var ids = $("#simple").val();
        layer_open('单图上传', "<?php echo url('/addons/web_uploader/upload/parent_ele/simple/id/" + ids + "'); ?>", {
            w: "600px",
            h: "400px"
        })
    });


    $("#form").Validform({
        tiptype: 2,
        showAllError: true,
        ajaxPost: true,
        callback: function (res) {
            if (res.success == true) {
                layer.msg(res.message, {time: 1000}, function () {
                    layer_close();
                    parent.window.location.reload();
//                    parent.$('#table').bootstrapTable('refresh');
                });
            } else {
                layer.alert(res.message);
            }
        }
    });


    var edit_data_url = "<?php echo url('ShopGoodsVariant/edit'); ?>";
    var delete_data_url = "<?php echo url('ShopGoodsVariant/delete'); ?>";

    //增加商品型号
    $("#variant-add").on("click",function () {
        var variantHTML = '<div class="form-group" style="margin-bottom: 5px;">'
                            +'<div class="col-sm-1"></div>'
                            +'<div class="panel panel-default col-sm-6" style="margin-bottom:5px;">'
                                +'<div class="panel-body">'
                                    +'<div class="form-group">'
                                        +'<label class="col-sm-2 control-label"><span style="color: red;">*</span>型号</label>'
                                        +'<div class="col-sm-6">'
                                            +'<input class="form-control" type="text" name="variant_name[]" datatype="*" nullmsg="请填商品型号">'
                                        +'</div>'
                                        +'<div class="col-sm-2"></div>'
                                    +'</div>'
                                    +'<div class="form-group">'
                                        +'<label class="col-sm-2 control-label"><span style="color: red;">*</span>价格</label>'
                                        +'<div class="col-sm-6">'
                                            +'<div class="input-group">'
                                                +'<span class="input-group-addon">￥</span>'
                                                +'<input name="variant_price[]" type="number" min="0" value="0" class="form-control" style="width: 100px;" datatype="*" nullmsg="请填商品价格">'
                                            +'</div>'
                                        +'</div>'
                                        +'<div class="col-sm-2"></div>'
                                    +'</div>'
                                +'</div>'
                            +'</div>'
                            +'<div class="col-sm-1" ><a href="javascript:;" onclick="remove_variant(this)"><i class="fa fa-trash-o" style="padding-top: 50%;padding-left: 50%;color: #f32310;"></i></a></div>'
                            +'</div>';
        $(this).parents(".form-group").before(variantHTML);
        goToElementPosition(this);
    });

    /**
     *删除商品型号
     */
    function remove_variant(e) {
        $(e).parents(".form-group").remove()
    }

    /**
     *设置滚动条位置
     */
    function goToElementPosition(e) {
        var docScrollTop = $(e).offset().top;
        $("body,html").animate({ scrollTop:  docScrollTop}, 1000);
    }

</script>

</html>